package com.llkj.contractmanagement.contractmanagement.login;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import com.llkj.contractmanagement.main.BaseActivity;
import com.llkj.contractmanagement.R;
import com.llkj.contractmanagement.customview.TitleBar;
import com.llkj.contractmanagement.http.UrlConfig;

import butterknife.Bind;

/**
 * author: dong.yj
 * created on: 2016/8/16 10:07
 * description:用户协议界面
 */
public class UserAgreementActivity extends BaseActivity {

    @Bind(R.id.title_useragreement)
    TitleBar titleBar;
    @Bind(R.id.webview_useragreement)
    WebView webView;

    @Override
    protected int getLayoutResId() {
        return R.layout.activity_useragreement;
    }

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        init();
    }

    private void init() {
        initWebview();
        titleBar.setTopBarClickListener(this);
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return super.shouldOverrideUrlLoading(view, url);
            }

            @Override
            public void onPageFinished(WebView view, String url) {
                super.onPageFinished(view, url);
                dismissWaitDialog();
            }

            @Override
            public void onPageStarted(WebView view, String url, Bitmap favicon) {
                super.onPageStarted(view, url, favicon);
                showWaitDialog();
            }
        });
    }

    private void initWebview() {
        WebSettings settings = webView.getSettings();
        settings.setJavaScriptEnabled(true);
        settings.setAllowFileAccess(true);
        settings.setLoadWithOverviewMode(false);
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);
        settings.setBuiltInZoomControls(true);
        settings.setSupportZoom(false);// 设定支持缩放
        webView.loadUrl(UrlConfig.USERAGREEMENT);
    }


}
